const initialState = {
    arr:[],
    searcharrall:[] // 用来保存arr的值，用来保存网络请求回来的20条数据，且这个数组被赋值后永远不改变
}

export default (state = initialState, { type, payload }) => {
  switch (type) {

  case "getlist":
      let newarr = [...state.arr]
      let newsearcharrall = payload
      newarr = payload
    return { ...state,arr:newarr,searcharrall: newsearcharrall}
  case "searchfn" :
      let searcharr = [...state.arr]
       
      let newarr1 =  state.searcharrall.filter((item,index)=>{
           return item.tit.includes(payload)
       })
       return {
           ...state,
           arr:newarr1
       }
  default:
    return state
  }
}
